package com.group.project.hrms.service.impl;

import com.group.project.hrms.entity.AttendanceGroupStaffs;
import com.group.project.hrms.mapper.AttendanceGroupStaffsMapper;
import com.group.project.hrms.service.IAttendanceGroupStaffsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class AttendanceGroupStaffsService implements IAttendanceGroupStaffsService {

    @Autowired
    private AttendanceGroupStaffsMapper attendanceGroupStaffsMapper;

    @Override
    public int insertAttendanceGroupStaffs(AttendanceGroupStaffs attendanceGroupStaffs) {
        return attendanceGroupStaffsMapper.insert(attendanceGroupStaffs);
    }

    @Override
    public int deleteAttendanceGroupStaffs(AttendanceGroupStaffs attendanceGroupStaffs) {
        return attendanceGroupStaffsMapper.deleteByPrimaryKey(attendanceGroupStaffs);
    }

    @Override
    public int updateAttendanceGroupStaffs(AttendanceGroupStaffs attendanceGroupStaffs) {
        return attendanceGroupStaffsMapper.updateByPrimaryKey(attendanceGroupStaffs);
    }

    @Override
    public AttendanceGroupStaffs selectOneAttendanceGroupStaffs(AttendanceGroupStaffs attendanceGroupStaffs) {
        return null;
    }

    @Override
    public AttendanceGroupStaffs selectOneAttendanceGroupStaffsByContactID(String cid) {
        Example example = new Example(AttendanceGroupStaffs.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orEqualTo("contactId" , cid);
        return attendanceGroupStaffsMapper.selectOneByExample(example);
    }

    @Override
    public List<AttendanceGroupStaffs> selectAttendanceGroupStaffsByGroupID(String gid) {
        Example example = new Example(AttendanceGroupStaffs.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orEqualTo("attendanceGroupId" , gid);
        return attendanceGroupStaffsMapper.selectByExample(example);
    }

    @Override
    public List<AttendanceGroupStaffs> selectAllAttendanceGroupStaffs() {
        return attendanceGroupStaffsMapper.selectAll();
    }
}
